package com.czbgradefive.shop.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.czbgradefive.common.log.annotation.Log;
import com.czbgradefive.common.log.enums.BusinessType;
import com.czbgradefive.common.security.annotation.RequiresPermissions;
import com.czbgradefive.shop.domain.MallProductBrandInfo;
import com.czbgradefive.shop.service.IMallProductBrandInfoService;
import com.czbgradefive.common.core.web.controller.BaseController;
import com.czbgradefive.common.core.domain.Result;
import com.czbgradefive.common.core.utils.poi.ExcelUtil;
import com.czbgradefive.common.core.domain.Result;
import com.czbgradefive.common.core.web.page.TableDataInfo;

/**
 * 商品品牌Controller
 * 
 * @author czbgradefive
 * @date 2024-05-06
 */
@RestController
@RequestMapping("/brand")
public class MallProductBrandInfoController extends BaseController
{
    @Autowired
    private IMallProductBrandInfoService mallProductBrandInfoService;

    /**
     * 查询商品品牌列表
     */
    @RequiresPermissions("shop:shop:list")
    @GetMapping("/list")
    public Result<TableDataInfo> list(MallProductBrandInfo mallProductBrandInfo)
    {
        startPage();
        List<MallProductBrandInfo> list = mallProductBrandInfoService.selectMallProductBrandInfoList(mallProductBrandInfo);
        return getDataTable(list);
    }

    /**
     * 导出商品品牌列表
     */
    @RequiresPermissions("shop:shop:export")
    @Log(title = "商品品牌", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallProductBrandInfo mallProductBrandInfo)
    {
        List<MallProductBrandInfo> list = mallProductBrandInfoService.selectMallProductBrandInfoList(mallProductBrandInfo);
        ExcelUtil<MallProductBrandInfo> util = new ExcelUtil<MallProductBrandInfo>(MallProductBrandInfo.class);
        util.exportExcel(response, list, "商品品牌数据");
    }

    /**
     * 获取商品品牌详细信息
     */
    @RequiresPermissions("shop:shop:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(mallProductBrandInfoService.selectMallProductBrandInfoById(id));
    }

    /**
     * 新增商品品牌
     */
    @RequiresPermissions("shop:shop:add")
    @Log(title = "商品品牌", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody MallProductBrandInfo mallProductBrandInfo)
    {
        return toAjax(mallProductBrandInfoService.insertMallProductBrandInfo(mallProductBrandInfo));
    }

    /**
     * 修改商品品牌
     */
    @RequiresPermissions("shop:shop:edit")
    @Log(title = "商品品牌", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody MallProductBrandInfo mallProductBrandInfo)
    {
        return toAjax(mallProductBrandInfoService.updateMallProductBrandInfo(mallProductBrandInfo));
    }

    /**
     * 删除商品品牌
     */
    @RequiresPermissions("shop:shop:remove")
    @Log(title = "商品品牌", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(mallProductBrandInfoService.deleteMallProductBrandInfoByIds(ids));
    }
}
